package org.apache.jsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.verbetia.musictrends.persistence.hsqldb.MusicEntity;

public final class rss_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/xml;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write('\r');
      out.write('\n');
      com.verbetia.musictrends.service.RssGenerator rssgen = null;
      synchronized (_jspx_page_context) {
        rssgen = (com.verbetia.musictrends.service.RssGenerator) _jspx_page_context.getAttribute("rssgen", PageContext.PAGE_SCOPE);
        if (rssgen == null){
          rssgen = new com.verbetia.musictrends.service.RssGenerator();
          _jspx_page_context.setAttribute("rssgen", rssgen, PageContext.PAGE_SCOPE);
        }
      }
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
 java.util.ArrayList a = rssgen.generateFeed(request.getParameter("u") ); 
      out.write("\r\n");
      out.write("<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\r\n");
      out.write("  <channel>\r\n");
      out.write("    <title>test listened  music</title>\r\n");
      out.write("    <link>http://www.musictrends.com/</link>\r\n");
      out.write("    <description>This feed has the Music gipsh have been listening.</description>\r\n");
      out.write("    <language>en-us</language>\r\n");
      out.write("    <pubDate>2008-04-13 22:28:51</pubDate>\r\n");
      out.write("    <docs>http://blogs.law.harvard.edu/tech/rss</docs>\r\n");
      out.write("    <generator>MusicTrends</generator>\r\n");
      out.write("    <image>\r\n");
      out.write("      <url>http://www.realfresh.tv/wp-content/uploads/images/2007/11/shamrock.gif</url>\r\n");
      out.write("      <title>MusicTrends: your music in feeds</title>\r\n");
      out.write("      <link>http://localhost:8080/MusicBrainz/rss.jsp</link>\r\n");
      out.write("    </image>\r\n");
      out.write("    <ttl>20</ttl>\r\n");
      out.write("    ");
  if (a!=null)
		   for (int i=0; i!=a.size(); i++) {
		   		
		   		MusicEntity data  = (MusicEntity)a.get(i);
		   
      out.write("            \r\n");
      out.write("    <item>\r\n");
      out.write("      <title>");
      out.print( data.getArtist() );
      out.write(' ');
      out.write('-');
      out.write(' ');
      out.print( data.getTitle() );
      out.write(' ');
      out.write('-');
      out.write(' ');
      out.print( data.getAlbum() );
      out.write("</title>\r\n");
      out.write("      <link>http://www.autolyrics.com/tema1en.php?songname=");
      out.print( data.getTitle() );
      out.write(' ');
      out.print( data.getArtist() );
      out.write("</link>     \r\n");
      out.write("      <description>\r\n");
      out.write("      &lt;a href=&quot;http://www.autolyrics.com/tema1en.php?songname=");
      out.print( data.getTitle() );
      out.write(' ');
      out.print( data.getArtist() );
      out.write("&quot; title=&quot;");
      out.print( data.getArtist() );
      out.write("&quot;&gt;&lt;img src=&quot;");
      out.print( data.getAmazonid() );
      out.write("&quot; alt=&quot;");
      out.print( data.getAlbum() );
      out.write("&quot; style=&quot;border: 1px solid #000000;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;\r\n");
      out.write("      </description>\r\n");
      out.write("      <pubDate>");
      out.print( data.getDateFormated("") );
      out.write("</pubDate>\r\n");
      out.write("      <enclosure url=\"");
      out.print( data.getAmazonid() );
      out.write("\"  type=\"image/jpeg\" />      \r\n");
      out.write("    </item>    \r\n");
      out.write("    ");
 } 
      out.write("\r\n");
      out.write("  </channel>\r\n");
      out.write("</rss>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
